package example.service;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import example.vo.Link;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;

@Log4j
@Service
public class DeleteServiceImpl implements DeleteService{

    public void deletestring(String firstKey) {
        log.info("Started");
        OSS ossClient = new OSSClientBuilder().build(Link.endpoint, Link.accessKeyId, Link.accessKeySecret);
        ossClient.deleteObject(Link.bucketName, firstKey);
        log.info("删除Object：" + firstKey + "成功。");
        ossClient.shutdown();
        log.info("Completed");
    }

    public void deletefile(String fileKey) {
        log.info("Started");
        OSS ossClient = new OSSClientBuilder().build(Link.endpoint, Link.accessKeyId, Link.accessKeySecret);
        ossClient.deleteObject(Link.bucketName, fileKey);
        log.info("删除Object：" + fileKey + "成功。");
        ossClient.shutdown();
        log.info("Completed");
    }
}
